﻿// Tribe Framework by Chinajade.
//
// LICENSE:
// This work is licensed under the
//     Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
// also known as CC-BY-NC-SA.  To view a copy of this license, visit
//      http://creativecommons.org/licenses/by-nc-sa/3.0/
// or send a letter to
//      Creative Commons // 171 Second Street, Suite 300 // San Francisco, California, 94105, USA.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Styx;
using Styx.WoWInternals;
using Styx.WoWInternals.WoWObjects;

namespace Chinajade.Tribe
{
    [RevisionControlId("$Id: TribeWoWObject.cs 11 2012-12-27 08:14:47Z chinajade247@gmail.com $")]
    public static class TribeExtensions_WoWObject
    {
        private static LocalPlayer Me { get { return (StyxWoW.Me); } }


        public static void Blacklist(this WoWObject wowObject,
                                     TribeBlacklist.BlacklistReason reason,
                                     TimeSpan timeSpan)
        {
            Tribe.Blacklist.Add(wowObject.Guid, reason, timeSpan);
        }


        public static bool IsBlacklisted(this WoWObject wowObject,
                                         TribeBlacklist.BlacklistReason reason)
        {
            return (Tribe.Blacklist.IsBlacklisted(wowObject.Guid, reason));
        }


        public static string LoggableIdentifier(this WoWObject wowObject)
        {
            if (wowObject.IsMe)
                { return ("Myself"); }

            if (wowObject is WoWPlayer)
            {
                WoWPlayer wowPlayer = wowObject as WoWPlayer;

                return (string.Format("{0}***x{1}({2}, Lvl{3})", wowPlayer.Name[0], wowPlayer.Guid.AsGuidHash(), wowPlayer.Class, wowPlayer.Level));
            }

            if (wowObject is WoWUnit)
            {
                WoWUnit wowUnit = wowObject as WoWUnit;

                if (wowUnit.IsPet)
                    { return ("Pet"); }
            }

            return (string.Format("{0}(x{1})", wowObject.Name, wowObject.Guid.AsGuidHash()));
        }
    }
}

